fx <- x3[, c(1, 50:55)] bgb <- x3[, c(1, 34:40)] stocks <- x3[, c(1, 57:64)] cab <- x3[, c(1, 26:32)] gdp <- x3[, c(1:8)]
par(mfrow=c(2, 1)) par(mfrow=c(1, 1)) #with(gdp, plot(x=DATE, y=GDP.JP, type=‘l’)) with(cab, plot(x=DATE, y=scale(CAB.JP), type=‘l’, xlab="“)) #with(bgb, plot(x=DATE, y=BGB.JP, type=‘l’)) with(fx, plot(x=DATE, y=scale(FX.JP), type=‘l’, xlab=”")) #with(stocks, plot(x=DATE, y=NK, type=‘l’))
with(cab, plot(x=DATE, y=scale(CAB.JP), type=‘l’, col=“blue”, ylab=“Scale”, main=“Current account balance V Dollar-Yen correlation”)) with(fx, lines(x=DATE, y=scale(FX.JP), type=‘l’, col=“red”)) legend(“topright”, c(“CAB”, “FX”), pch=“-”, col=c(“blue”, “red”)) text(x=as.Date(“2020-10-01”), y=1.0, label=“Cor=0.58”) cab_fit <- lm(DATE~scale(CAB.JP), cab) fx_fit <- lm(DATE~scale(FX.JP), fx) abline(cab_fit, col=“blue”) abline(fx_fit, col=“red”) grid() axis(2, at=x, labels=cab$DATE, las=2)
ir <- x3[, c(1, 42:48)] fx <- x3[, c(1, 50:55)] comms <- x3[, c(1, 68:72)] #plot(scale(IR.US)~DATE, ir, type=‘l’, ylim=c(-2, 3), yaxt=‘n’, ann=FALSE) plot(scale(IR.US)~DATE, ir, type=‘l’, ylim=c(-2, 3), main=“US interest rate V Euro/USD and GOLD”) lines(scale(FX.EU)~DATE, fx, type=‘l’, col=“red”) #lines(scale(GOLD)~DATE, comms, type=‘l’, col=“blue”, lty=3) lines(scale(GOLD)~DATE, comms, type=‘l’, col=“blue”) legend(“topright”, c(“IR.US”, “EURO”, “GOLD”), pch=“-”, col=c(“black”, “red”, “blue”)) grid() axis(2, at=ir\(US, las=2) axis(4, at=comms\)GOLD, labels=comms$GOLD,las=2)
plot(scale(IR.US)~DATE, ir, type=‘l’, ylim=c(-2, 3), main=“US interest rate V stock and consumer price”) stocks <- x3[, c(1, 57:64)] lines(scale(SP)~DATE, stocks, type=‘l’, lty=4, col=“skyblue”) cp <- x3[, c(1, 10:16)] lines(scale(CP.US)~DATE, cp, type=‘l’, lty=5, col=“pink”) legend(“topright”, c(“IR.US”, “S&P”, “CP.US”), pch=“-”, col=c(“black”, “skyblue”, “pink”)) grid()
plot(scale(IR.US)~DATE, ir, type=‘l’, ylim=c(-2, 3), main=“US interest rate V consumer price, unemployment”) uep <- x3[, c(1, 18:24)] names(uep) <- c(“DATE”, “US”, “CN”, “JP”, “EU”,“IN”, “SK”, “TW”) lines(scale(CP.US)~DATE, cp, type=‘l’, lty=5, col=“pink”) lines(scale(US)~DATE, uep, type=‘l’, lty=6, col=“green”) legend(“topright”, c(“IR.US”, “CP.US”, “UNEMP”), pch=“-”, col=c(“black”, “pink”, “green”)) grid()
x <- data.frame(cbind( scale(ir\(IR.US), scale(cp\)CP.US), scale(uep\(US), scale(comms\)GOLD), scale(stocks\(SP), scale(fx\)FX.EU))) names(x) <- c(“IR”, “CP”, “UEP”, “GOLD”, “S&P”, “EURO”) pairs(x)
reg <- function(x, y, …) { points(x,y, …) abline(lm(y~x)) }# made to draw regression line instead of lowess line
panel.cor <- function(x, y, digits = 2, prefix = "“, cex.cor, …) { usr <- par(”usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits = digits)[1] txt <- paste0(prefix, txt) text(0.5, 0.5, txt, cex = 1.1, font = 4) } #EXAMPLE OF USE: pairs(x, upper.panel = reg, # replace HERE for panel.smooth # cex = 1.5, pch = 19, col = adjustcolor(4, .4), cex.labels = 2, font.labels = 2, lower.panel = panel.cor)
x <- data.frame(cbind( scale(ir\(IR.EU), scale(cp\)CP.EU), scale(uep\(EU), scale(comms\)GOLD), scale(stocks\(DAX), scale(fx\)FX.EU) )) names(x) <- c(“IR”, “CP”, “UEP”, “GOLD”, “DAX”, “EURO”) pairs(x, upper.panel = reg, # replace HERE for panel.smooth # cex = 1.5, pch = 19, col = adjustcolor(4, .4), cex.labels = 2, font.labels = 2, lower.panel = panel.cor)
x <- data.frame(cbind( scale(ir\(IR.US), scale(cp\)CP.US), scale(uep\(US), scale(comms\)GOLD), scale(stocks\(SP), scale(fx\)FX.JP))) names(x) <- c(“IR”, “CP”, “UEP”, “GOLD”, “S&P”, “JPY”) pairs(x)
reg <- function(x, y, …) { points(x,y, …) abline(lm(y~x)) }# made to draw regression line instead of lowess line
panel.cor <- function(x, y, digits = 2, prefix = "“, cex.cor, …) { usr <- par(”usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits = digits)[1] txt <- paste0(prefix, txt) text(0.5, 0.5, txt, cex = 1.1, font = 4) } #EXAMPLE OF USE: pairs(x, upper.panel = reg, # replace HERE for panel.smooth # cex = 1.5, pch = 19, col = adjustcolor(4, .4), cex.labels = 2, font.labels = 2, lower.panel = panel.cor)
x <- data.frame(cbind( scale(ir\(IR.US), scale(cp\)CP.US), scale(uep\(US), scale(comms\)GOLD), scale(stocks\(SP), scale(fx\)FX.CN))) names(x) <- c(“IR”, “CP”, “UEP”, “GOLD”, “S&P”, “CHY”) pairs(x)
reg <- function(x, y, …) { points(x,y, …) abline(lm(y~x)) }# made to draw regression line instead of lowess line
panel.cor <- function(x, y, digits = 2, prefix = "“, cex.cor, …) { usr <- par(”usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits = digits)[1] txt <- paste0(prefix, txt) text(0.5, 0.5, txt, cex = 1.1, font = 4) } #EXAMPLE OF USE: pairs(x, upper.panel = reg, # replace HERE for panel.smooth # cex = 1.5, pch = 19, col = adjustcolor(4, .4), cex.labels = 2, font.labels = 2, lower.panel = panel.cor)